package cn.edu.java.stream.functionalinterface;

import java.util.function.UnaryOperator;

public class UnaryOperatorDemo {
    public static void main(String[] args) {
        UnaryOperator<Integer> square = new UnaryOperator<Integer>() {
            @Override
            public Integer apply(Integer number) {
                return number * number;
            }
        };

        int result = square.apply(5);
        System.out.println(result); // 输出：25

        UnaryOperator<Integer> square2 = number -> number * number;

        int result2 = square2.apply(5);
        System.out.println(result2); // 输出：25


    }
}
